package com.service;
import java.util.List;
import com.model.TZuopin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import com.mapper.TZuopinMapper;
@Service
public class TZuopinServiceImpl implements TZuopinService
{
        
        @Autowired
	private TZuopinMapper tZuopinMapper;


	public List<TZuopin> queryTZuopinList(TZuopin tZuopin) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		if(tZuopin!=null){
			 map.put("uid", tZuopin.getUid());
			 map.put("zid", tZuopin.getZid());
			 map.put("nl", tZuopin.getNl());
			 map.put("state", tZuopin.getState());
			 map.put("types", tZuopin.getTypes());
			 map.put("cateid", tZuopin.getCateid());
		}
		List<TZuopin> getTZuopin = tZuopinMapper.query(map);
		return getTZuopin;
	}

	
	public List<TZuopin> findTopZan(TZuopin tZuopin) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		if(tZuopin!=null){
			 map.put("uid", tZuopin.getUid());
			 map.put("zid", tZuopin.getZid());
			 map.put("nl", tZuopin.getNl());
			 map.put("state", tZuopin.getState());
		}
		List<TZuopin> getTZuopin = tZuopinMapper.findTopZan(map);
		return getTZuopin;
	}
	
	public int insertTZuopin(TZuopin tZuopin) throws Exception {
		
		return tZuopinMapper.insertTZuopin(tZuopin);
	}

	public int deleteTZuopin(int id) throws Exception {
		return tZuopinMapper.deleteTZuopin(id);
	}

	public int updateTZuopin(TZuopin tZuopin) throws Exception {
		return tZuopinMapper.updateTZuopin(tZuopin);
	}
	
	public TZuopin queryTZuopinById(int id) throws Exception {
		return tZuopinMapper.queryTZuopinById(id);
	}
 
}
